package com.lineage.server.command.executor;

import com.lineage.server.datatables.SprTable;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1Spr implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1Spr.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1Spr();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      int sprid = Integer.parseInt(arg);
      int attack1 = SprTable.get().getAttackSpeed(sprid, 1);
      int attack2 = SprTable.get().getAttackSpeed(sprid, 5);
      int attack3 = SprTable.get().getAttackSpeed(sprid, 12);
      int attack4 = SprTable.get().getAttackSpeed(sprid, 21);
      int attack5 = SprTable.get().getAttackSpeed(sprid, 25);
      int attack6 = SprTable.get().getAttackSpeed(sprid, 41);
      int attack7 = SprTable.get().getAttackSpeed(sprid, 47);
      int attack8 = SprTable.get().getAttackSpeed(sprid, 51);
      int attack9 = SprTable.get().getAttackSpeed(sprid, 55);
      int attack10 = SprTable.get().getAttackSpeed(sprid, 59);
      int attack11 = SprTable.get().getAttackSpeed(sprid, 63);
      int move = SprTable.get().getMoveSpeed(sprid, 0);
      int dmg = SprTable.get().getDmg(sprid);
      int attack12 = SprTable.get().getDirSpellSpeed(sprid);
      int attack13 = SprTable.get().getNodirSpellSpeed(sprid);
      int attack14 = SprTable.get().getDirSpellSpeed30(sprid);
      String info = "sprid:" + sprid + "\n\r 走路速度:" + move + "\n\r 攻击速度-空手:" + attack1 + "\n\r 攻击速度-单手剑:" + 
        attack2 + "\n\r 攻击速度-斧头:" + attack3 + "\n\r 攻击速度-弓:" + attack4 + "\n\r 攻击速度-矛:" + attack5 + 
        "\n\r 攻击速度-杖:" + attack6 + "\n\r 攻击速度-匕首:" + attack7 + "\n\r 攻击速度-双手剑:" + attack8 + 
        "\n\r 攻击速度-双刀:" + attack9 + "\n\r 攻击速度-爪:" + attack10 + "\n\r 攻击速度-铁手甲:" + attack11 + 
        "\n\r 受伤动作速度:" + dmg + "\n\r 有向施法速度:" + attack12 + "\n\r 无向施法速度:" + attack13 + "\n\r 特攻30速度:" + 
        attack14;
      if (pc == null) {
        _log.warn("系统命令执行: spr" + sprid + "\n\r" + info);
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage(info));
      } 
    } catch (Exception e) {
      if (pc == null) {
        _log.error("错误的命令格式: " + getClass().getSimpleName());
      } else {
        _log.error("错误的GM指令格式: " + getClass().getSimpleName() + " 执行的GM:" + pc.getName());
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
      } 
    } 
  }
}
